package com.neusoft.mapper;

import java.util.List;

import org.apache.ibatis.annotations.*;

import com.neusoft.po.Orders;

@Mapper
public interface OrdersMapper {

	@Insert("insert into orders(userId,businessId,orderDate,orderTotal,daId,orderState) values(#{userId},#{businessId},#{orderDate},#{orderTotal},#{daId},0)")
	@Options(useGeneratedKeys=true,keyProperty="orderId",keyColumn="orderId")
	public int saveOrders(Orders orders);

	@Update("update orders set orderTotal=#{orderTotal} where orderId=#{orderId}")
	public Integer updateOrders(@Param("orderTotal") Double orderTotal,@Param("orderId")Integer orderId);

	@Select("select * from orders where orderId=#{orderId}")
	public Orders getOrdersById(Integer orderId);

	@Select("select * from orders where userId=#{userId} order by orderId")
	public List<Orders> listOrdersByUserId(String userId);

	@Update("update orders set orderState=1 where orderId=#{orderId}")
	public int pay(Integer orderId);
}
